home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 003 / xlisp / xlisp.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  2KB  |  90 lines

  1. /* xlisp - an experimental version of lisp that supports object-oriented
  2.            programming */
  3.  
  4. #include "xlisp.h"
  5.  
  6. /* define the banner line string */
  7. #define BANNER    "XLISP version 1.4 - 14-FEB-1985, by David Betz"
  8.  
  9. /* external variables */
  10. extern NODE *s_stdin,*s_stdout;
  11. extern NODE *s_evalhook,*s_applyhook;
  12. extern NODE *true;
  13.  
  14. /* main - the main routine */
  15. main()
  16. /*
  17. main(argc,argv)
  18.   int argc; char *argv[];
  19. */
  20. {
  21.     NODE expr;
  22.     CONTEXT cntxt;
  23.     int i;
  24.  
  25.     /* print the banner line */
  26. #ifdef MEGAMAX
  27.     _autowin(BANNER);
  28. #else
  29.     printf("%s\n",BANNER);
  30. #endif
  31.  
  32.     /* setup initialization error handler */
  33.     xlbegin(&cntxt,CF_ERROR,(NODE *) 1);
  34.     if (setjmp(cntxt.c_jmpbuf)) {
  35.     printf("fatal initialization error\n");
  36.     exit();
  37.     }
  38.  
  39.     /* initialize xlisp */
  40.     xlinit();
  41.     xlend(&cntxt);
  42.  
  43.     /* reset the error handler */
  44.     xlbegin(&cntxt,CF_ERROR,true);
  45.  
  46.     /* load "init.lsp" */
  47.     if (setjmp(cntxt.c_jmpbuf) == 0)
  48.     xlload("init",FALSE,FALSE);
  49.  
  50.     /* load any files mentioned on the command line */
  51. /**
  52.     if (setjmp(cntxt.c_jmpbuf) == 0)
  53.     for (i = 1; i < argc; i++)
  54.         if (!xlload(argv[i],TRUE,FALSE)) xlfail("can't load file");
  55. **/
  56.  
  57.     /* create a new stack frame */
  58.     xlsave(&expr,NULL);
  59.  
  60.     /* main command processing loop */
  61.     while (TRUE) {
  62.  
  63.     /* setup the error return */
  64.     if (setjmp(cntxt.c_jmpbuf)) {
  65.         s_evalhook->n_symvalue = NIL;
  66.         s_applyhook->n_symvalue = NIL;
  67.         xlflush();
  68.     }
  69.  
  70.     /* read an expression */
  71.     if (!xlread(s_stdin->n_symvalue,&expr.n_ptr))
  72.         break;
  73.  
  74.     /* evaluate the expression */
  75.     expr.n_ptr = xleval(expr.n_ptr);
  76.  
  77.     /* print it */
  78.     stdprint(expr.n_ptr);
  79.     }
  80.     xlend(&cntxt);
  81. }
  82.  
  83. /* stdprint - print to standard output */
  84. stdprint(expr)
  85.   NODE *expr;
  86. {
  87.     xlprint(s_stdout->n_symvalue,expr,TRUE);
  88.     xlterpri(s_stdout->n_symvalue);
  89. }
  90.